﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeArt.SharePoint.Configuration
{
    using System.Configuration;

	public class PickerControlElement : ConfigurationElementBase
    {
        /// <summary>
        /// Title
        /// </summary>
        [ConfigurationProperty("title", IsRequired = true)]
        public string Title
        {
            get { return (string)this["title"]; }
        }

        /// <summary>
        /// KeyField
        /// </summary>
        [ConfigurationProperty("description", IsRequired = true)]
        public string Description
        {
            get { return (string)this["description"]; }
        }


        [ConfigurationProperty("query",IsRequired=true)]
        public QueryElement Query
        {
            get
            {
                return (QueryElement)this["query"];
            }
        }

        ///// <summary>
        ///// lookupIDField
        ///// </summary>
        //[ConfigurationProperty("lookupIDField", IsRequired = true)]
        //public string LookupIDField
        //{
        //    get { return (string)base["lookupIDField"]; }
        //}

        ///// <summary>
        ///// lookupNameField
        ///// </summary>
        //[ConfigurationProperty("lookupNameField", IsRequired = true)]
        //public string LookupNameField
        //{
        //    get { return (string)base["lookupNameField"]; }
        //}

        /// <summary>
        /// ViewFields
        /// </summary>
        [ConfigurationProperty("viewFields", IsRequired=true)]
        public ViewFieldsElement ViewFields
        {
            get
            {
                return (ViewFieldsElement)base["viewFields"];
            }
        }
    }

    public class QueryElement : ConfigurationTextElement
    {        
        /// <summary>
        /// lookupIDField
        /// </summary>
        [ConfigurationProperty("rowLimit", IsRequired = false, DefaultValue=0)]
        public int RowLimit
        {
            get {
                object obj = base["rowLimit"];
                return obj == null ? 0 : Convert.ToInt32(obj);
                }
        }

        /// <summary>
        /// KeyField
        /// </summary>
        [ConfigurationProperty("connectionName", IsRequired = true)]
        public string ConnectionName
        {
            get { return (string)this["connectionName"]; }
        }

        //[ConfigurationProperty("text", IsRequired = true)]
        //public string Text
        //{
        //    get
        //    {
        //        return (string)base["text"];
        //    }
        //}
        
    }

}
